package com.xquant.transaction_management_system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xquant.transaction_management_system.model.PO.Account;
import com.xquant.transaction_management_system.model.PO.FinancialInstruments;
import com.xquant.transaction_management_system.service.AccountService;
import com.xquant.transaction_management_system.utils.Result;
import io.swagger.annotations.Api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("帐户服务控制层")
@RestController
@CrossOrigin
@RequestMapping("/admin")
public class AccountController {
    @Autowired
    private AccountService accountService;

    @PostMapping("/login")
    private Result login(@RequestBody Account account) {

        boolean loginStatus = accountService.login(account);

        if (loginStatus) {
            System.out.println(account.getTransactionAccount());

            return Result.ok(account.getTransactionAccount());
        }
        return Result.fail();
    }
    @GetMapping("/getAccount")
    public Result getAccount(){
        List<Account> pages = accountService.getAll();
        return Result.ok(pages);
    }
}
